#pragma once

#include <Thresholds.hpp>
#include <Utils.hpp>
#include <boost/asio/streambuf.hpp>
#include <boost/container/flat_map.hpp>
#include <gpiod.hpp>
#include <sdbusplus/asio/object_server.hpp>
#include <sensor.hpp>

#include <filesystem>
#include <fstream>
#include <memory>
#include <stdexcept>
#include <string>
#include <variant>
#include <vector>



class CPUSensor
{
  public:
    CPUSensor(boost::asio::io_context& ioc, sdbusplus::asio::connection& bus,
                sdbusplus::asio::object_server& objServer) :
        ioc_(ioc),
        bus_(bus), objServer_(objServer)
    {
    
    }

    uint32_t fatalErrors() const;

    auto logSystemErrorCode(boost::system::error_code ec);

    void logException(const std::exception& e);

    void logBadProperty(const std::string& badProperty);
    void logExpectedException(
    const sdbusplus::exception::UnpackPropertyError& error);

    void asyncReadProperties();

    void asyncChangeProperty(uint8_t cpu0_freq,uint8_t cpu1_freq);

  private:
    boost::asio::io_context& ioc_;
    sdbusplus::asio::connection& bus_;
    sdbusplus::asio::object_server& objServer_;
     void PhytSetCPUTempLimitParam(void);
    void PhytSetCPUTempLimit(void);

    uint8_t CPU0_Temp;
    uint8_t CPU1_Temp;
    uint8_t CPU0_Freq;
    uint8_t CPU1_Freq;
    uint8_t CPU0_Threshold;
    uint8_t CPU1_Threshold;
};